#include "stdafx.h"
#include "net/DatagramSocketImpl.hpp"

NET_NAMESPACE_BEGIN

CDatagramSocketImpl::CDatagramSocketImpl()
{
	init(AF_INET);
}

CDatagramSocketImpl::CDatagramSocketImpl(CIPAddress::Family family)
{
	if (family == CIPAddress::IPv4)
		init(AF_INET);
#if defined(JH_HAVE_IPv6)
	else if (family == CIPAddress::IPv6)
		init(AF_INET6);
#endif
	else 
		throw InvalidArgumentException("Invalid or unsupported address family passed to DatagramSocketImpl");
}

CDatagramSocketImpl::CDatagramSocketImpl(JH_SOCKET sockfd) : CSocketImpl(sockfd)
{
}

CDatagramSocketImpl::~CDatagramSocketImpl()
{
}

void CDatagramSocketImpl::init(int af)
{
	initSocket(af, SOCK_DGRAM);
}

NET_NAMESPACE_END
